import 'package:cat_eye/config/color_config.dart';
import 'package:cat_eye/config/string_config.dart';
import 'package:cat_eye/root_page/find_page/find_classification_widget.dart';
import 'package:cat_eye/root_page/find_page/find_follow_widget.dart';
import 'package:cat_eye/root_page/find_page/find_info_widget.dart';
import 'package:cat_eye/root_page/find_page/find_recommend_widget.dart';
import 'package:cat_eye/root_page/find_page/find_special_widget.dart';
import 'package:cat_eye/util/util.dart';
import 'package:flutter/material.dart';

/*
* @Package: home_page
* @ClassName: find_page
* @Author: szj
* @CreateDate: 7/28/21 1:20 PM
* TODO 发现页面
*/
class FindPageWidget extends StatefulWidget {
  const FindPageWidget({Key key}) : super(key: key);

  @override
  _FindPageWidgetState createState() => _FindPageWidgetState();
}

class _FindPageWidgetState extends State<FindPageWidget>
    with SingleTickerProviderStateMixin {
  TabController _tabController;

  @override
  void initState() {
    super.initState();
    _tabController =
        TabController(vsync: this, length: StringConfig.FIND_TAB_TITLE.length);
  }

  @override
  void dispose() {
    _tabController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: appBar(
        StringConfig.FIND,backgroundColor: ColorConfig.themeColor,
        bottom: TabBar(
          //可滑动
          isScrollable: true,
          //TabBar和TabBarView controller 必须统一
          controller: _tabController,
          //字体颜色
          labelColor: Colors.black,
          //滑动条颜色
          indicatorColor: themeColor(),
          tabs: initTabData(),
        ),
      ),
      body: TabBarView(
        controller: _tabController,
        //注意,这里数据必须和TabBar中的数据统一
        children: [
          //关注页面
         FindFollowWidget(),

          //分类页面
          FindClassificationWidget(),

          //专题页面
          FindSpecialWidget(),

          //资讯
          FindInfoWidget(),

          //推荐
          FindRecommendWidget(),

        ],
      ),
    );
  }

  List<Widget> initTabData() {
    List<Tab> tabList = [];
    StringConfig.FIND_TAB_TITLE.forEach((element) {
      tabList.add(Tab(
        text: element,
      ));
    });
    return tabList;
  }
}
